package queue;

import java.util.concurrent.ArrayBlockingQueue;

public class ArrayQueueDemo {
    private final static ArrayBlockingQueue<Integer> queue= new ArrayBlockingQueue<>(4);
//    private final static LinkedBlockingQueue<Integer> queue= new LinkedBlockingQueue<>(4);
    public static void main(String[] args) {
        new Thread(()->{
            try {
                queue.add(2);
                queue.add(2);
                queue.remove(2);
                queue.add(12);
                queue.put(12);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(()->{
            try {
                Thread.sleep(2000);
                Integer take = queue.take();
                Integer take1 = queue.take();
                System.out.println(take);
                System.out.println(take1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
